function plotsubmesh2(outputdir_in)

global outputdir
if(nargin<1)
  outputdir='mesh_output';
else
  outputdir=outputdir_in;
end

% TITLE INFO --------------------------------------------------------------
disp(' ')
disp('  2D UNSTRUCTURED GRID PLOTTING ROUTINE')
disp(' ')
% END TITLE INFO ----------------------------------------------------------

disp(' Loading grid data: please wait ...');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% READ-IN MESH INFO %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fids = fopen([outputdir '/mesh_params.dat'],'r');
if fids==-1
  disp(' ');
  error(['File  ',outputdir,'/mesh_params.dat  not found.']);
end
NumElems = fscanf(fids,'%d',1);  fscanf(fids,'%s',1); fscanf(fids,'%s',1);
NumPhysElems = fscanf(fids,'%d',1);  fscanf(fids,'%s',1); fscanf(fids,'%s',1);
NumGhostElems = fscanf(fids,'%d',1);  fscanf(fids,'%s',1); fscanf(fids,'%s',1);
NumNodes = fscanf(fids,'%d',1);  fscanf(fids,'%s',1); fscanf(fids,'%s',1);
NumPhysNodes = fscanf(fids,'%d',1);  fscanf(fids,'%s',1); fscanf(fids,'%s',1);
NumBndNodes = fscanf(fids,'%d',1);  fscanf(fids,'%s',1); fscanf(fids,'%s',1);
NumEdges = fscanf(fids,'%d',1);  fscanf(fids,'%s',1); fscanf(fids,'%s',1);
fclose(fids);

fids = fopen([outputdir '/mesh_tnode.dat'],'r');
tmp = fscanf(fids,'%d %d %d',[3,inf]);
fclose(fids);
tnode = transpose(tmp);
clear tmp;

fids = fopen([outputdir '/mesh_node.dat'],'r');
tmp = fscanf(fids,'%e',[2,inf]);
fclose(fids);
node = transpose(tmp);
clear tmp;

fids = fopen([outputdir '/mesh_bnd_node.dat'],'r');
tmp = fscanf(fids,'%d',[1,inf]);
fclose(fids);
bnd = transpose(tmp);
clear tmp;
for i=1:length(bnd)
  bnd_node(i,1:2) = node(bnd(i),1:2);
end

fids = fopen([outputdir '/submesh_params.dat'],'r');
if fids==-1
  disp(' ');
  error(['File  ',outputdir,'/submesh_params.dat  not found.']);
end
SubFactor       = fscanf(fids,'%d',1);  fscanf(fids,'%s',1); fscanf(fids,'%s',1);
SubNumPhysElems = fscanf(fids,'%d',1);  fscanf(fids,'%s',1); fscanf(fids,'%s',1);
SubNumPhysNodes = fscanf(fids,'%d',1);  fscanf(fids,'%s',1); fscanf(fids,'%s',1);
SubNumBndNodes  = fscanf(fids,'%d',1);  fscanf(fids,'%s',1); fscanf(fids,'%s',1);
fclose(fids);

fids = fopen([outputdir '/submesh_tnode.dat'],'r');
tmp = fscanf(fids,'%d %d %d',[3,inf]);
fclose(fids);
sub_tnode = transpose(tmp);
clear tmp;

fids = fopen([outputdir '/submesh_node.dat'],'r');
tmp = fscanf(fids,'%e',[2,inf]);
fclose(fids);
sub_node = transpose(tmp);
clear tmp;

fids = fopen([outputdir '/submesh_bnd_node.dat'],'r');
tmp = fscanf(fids,'%d',[1,inf]);
fclose(fids);
bnd = transpose(tmp);
clear tmp;
for i=1:length(bnd)
  sub_bnd_node(i,1:2) = sub_node(bnd(i),1:2);
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

disp(' Finished loading grid data.');
disp(' ');

xmin = min(node(1:NumPhysNodes,1));
ymin = min(node(1:NumPhysNodes,2));
xmax = max(node(1:NumPhysNodes,1));
ymax = max(node(1:NumPhysNodes,2));

xtmp = 0.01*(xmax-xmin);
ytmp = 0.01*(ymax-ymin);

xmin = xmin - xtmp;
xmax = xmax + xtmp;

ymin = ymin - ytmp;
ymax = ymax + ytmp;


figure(1);
clf;
ztri=trisurf(tnode(1:NumPhysElems,:),node(1:NumPhysNodes,1),node(1:NumPhysNodes,2),...
             zeros(size(node(1:NumPhysNodes,1)))); 
colormap('jet');
axis on; box on; grid off;
axis('equal');
axis([xmin xmax ymin ymax]);
set(gca,'fontsize',14);
t1 = title('Mesh Generated by MeshGenC++');
set(t1,'fontsize',14);
set(gca,'plotboxaspectratio',[1 1 1]);
hold on;
pm=plot(bnd_node(:,1),bnd_node(:,2),'bo');
set(pm,'linewidth',1);
set(pm,'markersize',8);
set(pm,'MarkerFaceColor','b');
hold off;

figure(2);
clf;
ztri=trisurf(sub_tnode(1:SubNumPhysElems,:),sub_node(1:SubNumPhysNodes,1),sub_node(1:SubNumPhysNodes,2),...
             zeros(size(sub_node(1:SubNumPhysNodes,1)))); 
colormap('jet');
axis on; box on; grid off;
axis('equal');
axis([xmin xmax ymin ymax]);
set(gca,'fontsize',14);
t1 = title(['Sub-Mesh with SubFactor = ',num2str(SubFactor)]);
set(t1,'fontsize',14);
set(gca,'plotboxaspectratio',[1 1 1]);
hold on;
pm=plot(sub_bnd_node(:,1),sub_bnd_node(:,2),'bo');
set(pm,'linewidth',1);
set(pm,'markersize',8);
set(pm,'MarkerFaceColor','b');
hold off;

figure(1)


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%  CALL EXTRA FUNCTION, SPECIFIED BY USER
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
plot_subextra
